package com.aisino.mvpdesignproject2.ui.model;

import com.aisino.mvpdesignproject2.bean.MyNewsBean;
import com.aisino.mvpdesignproject2.http.api.ApiService;
import com.aisino.mvpdesignproject2.http.itf.Stateful;
import com.aisino.mvpdesignproject2.http.rxjava.BaseObserver;
import com.aisino.mvpdesignproject2.http.uitl.RetrofitManager;
import com.aisino.mvpdesignproject2.ui.contract.BaseContract;
import com.aisino.mvpdesignproject2.ui.presenter.BasePresenter;
import com.blankj.utilcode.util.LogUtils;

import io.reactivex.disposables.Disposable;

public class BaseModel extends BasePresenter implements BaseContract.Model {


    @Override
    public void getAllDate(final BaseContract.Presenter presenter) {
        invoke(RetrofitManager.getManager().getRetrofit().create(ApiService.class).getNewsList(""), new BaseObserver<MyNewsBean>() {
            @Override
            public void onSuccess(MyNewsBean o) {
                LogUtils.e("onSuccess");
                presenter.onSuccess((MyNewsBean)o);
            }

            @Override
            public void onFailed(String msg) {
                LogUtils.e("onFailed");
                presenter.onFail(msg);
            }

            @Override
            public void onSubcribes(Disposable d) {
                LogUtils.e("onSubcribes");
            }
        });
    }
}
